<?php 
$user=$session->read('User');
$colleageid=$session->read("colleageid");
?>
<div class="right_side_operate_area">
<div class="right_side_title left">
		<h2>
		<?php 
		$colleagename=$session->read("colleagename");
		echo $html->link($colleagename,"/colleages/showcolleageinfo/".$colleageid);
		?>
		</h2>
		<div class="clear"></div>
	</div>	
    <div class="right item_add_btn">
    <?php 
    	$id=$form->value('CgDemand.id');
    	$str_title=__("Add",true);
		if($id){
			$str_title=__("Edit",true);
		}
		echo $html->link(__("Cancel",true).$str_title,"/colleages/demand/");
    ?>
    </div>
    <div class="clear"></div>
</div>

<?php 
        $radiovalue=array("1"=>"是","0"=>"否");
        $attributes=array('legend'=>false,'onclick'=>'setuniversty_rely(this)');
?>


<div class="right_side_scollbar">
    <div class="detail_info_panel">   
    	<?php echo $form -> create('colleages', array('action' => 'editdemand','type'=> 'post','onsubmit'=>'return  checkedsave()') ); ?>    	    	        
	    	<div class="details_item_line">
			      <div class="details_item">
				      <div class="form_left_title left">标题：</div>
				      <div class="form_right_e_input left"><?php echo $form->text('CgDemand.title');?></div>
				       <div id='titlemessage' style='display:none;' class="error_message">请填写标题</div>
			      </div>
			</div>
			
			<div class="details_item_line">
			      <div class="details_item">
				      <div class="form_left_title left">发布人：</div>
				      <div class="form_right_e_input left"><?php echo $form->text('CgDemand.publisher');?></div>				    
			      </div>
		  </div>			      
			<div class="details_item_line">
			        <div class="details_item">
				      <div class="form_left_title left">有效期：</div>
				      <div class="form_right_e_input left">
				      <?php echo $form->text('CgDemand.validity',array("placeholder"=>"","onkeydown"=>"checkpricekeyup2(this,event)"));?>天</div>			     				 		    
			      </div>
			</div>
			
			<div class="details_item_line">
			      <div class="details_item">
				      <div class="form_left_title left">需求类型：</div>
				      <div class="form_right_input left">
				      <?php echo $form->select('CgDemand.require_type',$type, null,null,null);?></div>				      
			      <div id='typemessage' style='display:none;' class="error_message">请选择类型</div>
			      </div>
		   </div>

		<?php if($id){?>
		    <div class="details_item_line">  
	         <div class="details_item">
                <div class="form_left_title left"><?php echo "提醒到企业" ;?>：</div>
                <div class="form_right_input left">
	                <?php 
	                $is_alert=$form->value('CgDemand.is_alert');
	                if($is_alert == "0") echo "否";
	                else if($is_alert == "1") echo "是";
	                ?>
            	</div>
	         </div> 
         </div>
	    <?php }else{?>
	    <div class="details_item_line">
			<div class="details_item">	
				<div class="form_left_title left"><?php echo "提醒到企业" ;?>：</div>
			    <div class="form_right_e_input left"><?php echo $form->radio('CgDemand.is_alert',$radiovalue,$attributes);?></div>
			    <div id='alertmessage' style='display:none;' class="error_message">请选择类型</div>
	    	</div>
	    </div> 
	    <?php }?>
	    
		<?php 
        	$industrydisplay="none";
        	$isalert=$form->value('CgDemand.is_alert');
        	if($isalert){
        		$industrydisplay="block";
        	}
        ?>
        <div class="details_item_line" id="universty_rely" style="display:<?php echo $industrydisplay ?>">
           <div class="details_item">
            	 <div class="form_left_title left">所属产业：</div>
            	 <div class="form_right_add left">
                	<?php 
		            $industryidlist="";
		            if($industrys_cvalues){
			            foreach($industrys_cvalues as $industrys_cvalue){
			            	if(!empty($industrys_cvalue["cvid"])){
			            		$industryidlist.=$industrys_cvalue["cvid"].',';
			            	}
			            }
		            }
		            ?>
		            <div id="pcvalueidlist" class="txthide"><?php echo $industryidlist?></div>
                	<div id="taglist" class="added_item_list left"></div>
                    <div class="add_item_btn left">
                    	<?php if(!$id){?>
	                    <a id="add_drop_float_click" href="javascript:void(0)"><?php __("Add")?></a>
	                    <?php }?>
		                <div id="add_float_box" class="add_float_box" style="display:none;">
		                    <ul>
			                    <?php 
			                    $dan="'";
			                    foreach($industrys as $key=>$industry){
									echo "<li><label>";
									echo '<input type="checkbox" id="chbox'.$key.'" onclick="settxt(this,'.$dan.$industry.$dan.','.$dan."#ProjectIndustryname".$dan.','.$dan."#ProjectIndustryid".$dan.','.$dan."#taglist".$dan.','.$dan."add_drop_float_click".$dan.')" value="'.$key.'" />'.$industry;
									echo "</label></li>";
									echo "<span id='span".$key."' class='txthide'>".$industry."</span>";
								}?> 
							</ul>
		                </div>
					</div>
					<div id='industrymessage' style='display:none;' class="error_message">请选择产业</div>
                    <?php echo $form->text('Project.industryname',array('class'=>'txthide','readonly'=>'true','style'=>'width:500px'));?>
		            <?php echo $form->text('Project.industryid',array('class'=>'txthide'));?>
                </div>
            </div>
        </div>
			      
			<div class="details_item_line">
			      <div class="details_item">
				      <div class="form_left_title left">需求描述：</div>
				      <div class="form_right_e_input left"><?php echo $form->textarea('CgDemand.need');?></div>
			      </div>
			</div>
			
			<div class="details_item_line">
				<div class="details_item">
						<div class="form_left_title left"></div>
				        <div class="form_add_submit left">
				        	<?php echo $form->submit(__('Save',true), array("id"=>"adduser","name"=>"submit","class"=>"buttom","div"=>false));?>
				        	<?php echo $form->hidden('CgDemand.id')?>
				        	<?php echo $form->hidden('CgDemand.colleage_id',array("value"=>$colleageid));?>
				        </div>
				 </div>
		   </div>
       </form>
    </div>
</div>

<?php echo $javascript->link('project.js');?>

<script>
function setuniversty_rely(obj)
{
	var isflag=obj.value;
	if(isflag=="1"){
		$("#universty_rely").attr("style","display:block");
	}else{
		$("#universty_rely").attr("style","display:none");
	}
}


$("#CgDemandRequireType option:first").html('请选择类型');
function checkedsave(){
	 if($("#CgDemandTitle").val().trim() == ''){
			$("#titlemessage").css('display','block');
			return false;
	  }else{
		 	 $("#titlemessage").css('display','none');
		  }
		  	
	  if($("#CgDemandRequireType").val().trim() == ''){
		$("#typemessage").css('display','block');
		return false;
     }else{
	 	 $("#typemessage").css('display','none');
	 }	  		  	   
}


function addEV(C,B,A){
	if(window.attachEvent){
		C.attachEvent("on"+B,A);
	}else{
		if(window.addEventListener){
			C.addEventListener(B,A,false);
		}
	}
}
addEV(document,"click",function(E){
	var E=E||window.event;
	var A=E.target||E.srcElement;
	var D=window.event?E.button:E.which;
	var C=G("add_drop_float_click"),B=G("add_float_box");
	while(A&&A!=document.body&&A.tagName.toLowerCase()!="html"){
		if(A==C){break}
		if(A==B){break}
		A=A.parentNode
	}
	if(A==B){
		if(B!=null){
			B.style.display="block";
		}
	}else if(A!=C){
		if(B!=null){
			B.style.display="none";
		}
	}else{
		if(D<2){
			B.style.display=B.style.display=="block"?"none":"block";
		}
	}
});
</script>